package top.zxybird.yun.common;

/**
 * all URL params key and default value
 *
 * @author caorong
 */
public enum URLParamType {
  // ******************* version *******************
  _minSupportVersion("_minSupportVersion", "2.0.0"),
  _recommendVersion("_recommendVersion", "3.0.0"),

  // ******************* iface *******************
  // e.g xxxService.Iface.class
  iface("iface", null),
  enable("enable", false),
  async("async", true),
  // ******************* filter *******************
  // filters (split by ',')
  filters("_filters", ""),

  // filter options
  openLog("openLog", ""),

  // *********** registry ***********
  registry("_registry", "zookeeper"),
  registryAddress("_registryAddress", ""),
  registryTimeout("_registryTimeout", 2000),
  registrySessionTimeout("_registrySessionTimeout", 20000),
  registryLegacy("_registryLegacy", false),

  // *********** admin ***********
  adminAddress("_adminAddress", ""),

  // *********** metric ***********
  // timeout timestamp
  defaultTimeoutTs("_defaultTimeout", 5000),
  metricCollectorDelayedSec("_metricCollectorDelayedSec", 60),
  metricCollectorIntervalSec("_metricCollectorIntervalSec", 5),
  @Deprecated
  metricCollectorAddress("_metricCollectorAddress", ""), // deprcaetd
  enableMetricXdcsLog("_enableMetricXdcsLog", true), enableMetricConsoleReport("_enableMetricConsoleReport", false),
  metricConsoleReportIntervalSec("_metricConsoleReportIntervalSec", 60),

  // *********** scope ***********
  scope("scope", "default"),

  // *********** cluster ***********
  cluster("cluster", "failfast"), spliterCls("spliterCls", "spliterCls not exists!"), mergerCls("mergerCls",
      "mergerCls not exists!"),

  // *********** loadbalance ***********
  loadbalance("loadbalance", "random"),
  // for dbconsistenceHash
  dbconsistentHashJdbcDriver("dbconsistentHashJdbcDriver", "com.mysql.jdbc.Driver"), dbconsistentHashRoutingJdbcUrl(
      "dbconsistentHashRoutingJdbcUrl", ""), dbconsistentHashRoutingJdbcUser("dbconsistentHashRoutingJdbcUser", ""),
  dbconsistentHashRoutingJdbcPassword("dbconsistentHashRoutingJdbcPassword", ""), dbconsistentHashRoutingTable(
      "dbconsistentHashRoutingTable", ""),

  // ***************** router *****************
  routerScript("routerScript", ""),

  // ***************** proxy *******************
  proxyFactory("_proxyFactory", "jdk"),

  // ***************** protocol ****************
  protocol("protocol", "thrift"), multiplex("multiplex", false),

  // *********** transporter ************
  // default use netty
  transporter("transporter", "netty"),
  // netty server acceptor thread

  acceptorThread("_acceptorThread", 2),
  // netty server worker thread
  workerThread("_workerThread", 20),
  // netty server / client thread/ handle netty IO
  ioThread("_ioThread", 8),
  // max server conn (all clients conn)
  maxServerConnection("_maxServerConnection", 100000),
  // message handler threadpool queue size
  workerQueueSize("_workerQueueSize", 10),
  /** backlog: linux 连接队列的长度 **/
  backlog("_backlog", 2000),
  /** use netty native default false **/
  enableNettyNative("_enableNettyNative", false),

  // client connect to server timeout
//  soTimeout("_soTimeout", 5000),
  // client request channel from pool timeout
  requestConnectionTimeout("_requestConnectionTimeout", 5000),
  /** pool max conn number **/
  maxClientConnection("_maxClientConnection", 4),
  /** pool max pending size (because we use async) **/
  maxClientPendingAcquireSize("_maxClientPendingAcquireSize", 4000),
  /** heart beat interval millsecond deprcated **/
  heartBeatIntervalMillSec("_heartBeatIntervalMillSec", 1000 * 30), idleCheckIntervalSec("_idleCheckIntervalSec",
      1000 * 300),
  /** custom thread pool use json @see CustomPoolConfig */
  customThreadPoolConfig("_customThreadPoolConfig", ""),

  port("port", 9876), ip("ip", "127.0.0.1"),
  // future.get default timeout == waiting server response timeout
  timeout("_timeout", 20000),
  // enableXdcs only for print
  enableXdcs("_enableXdcs", ""),
  ;

  public static enum ThriftProtocolType {
    compact, binary, json, xdcs
  }

  private String name;
  private String value;
  private long longValue;
  private int intValue;
  private boolean boolValue;

  URLParamType(String name, String value) {
    this.name = name;
    this.value = value;
  }

  URLParamType(String name, long longValue) {
    this.name = name;
    this.longValue = longValue;
  }

  URLParamType(String name, int intValue) {
    this.name = name;
    this.intValue = intValue;
  }

  URLParamType(String name, boolean boolValue) {
    this.name = name;
    this.boolValue = boolValue;
  }

  public String getName() {
    return name;
  }

  public String getValue() {
    return value;
  }

  public long getLongValue() {
    return longValue;
  }

  public int getIntValue() {
    return intValue;
  }

  public boolean getBoolValue() {
    return boolValue;
  }
}
